package org.groupg.practice.configuration.validator;

import org.apache.commons.configuration2.Configuration;

public class DefaultValueValidator implements ConfigurationValidator {
    private final String key;
    private final Object defaultValue;

    public DefaultValueValidator(String key, Object defaultValue) {
        this.key = key;
        this.defaultValue = defaultValue;
    }

    @Override
    public void validate(Configuration config) {
        if (!config.containsKey(key)) {
            config.setProperty(key, defaultValue);
        }
    }
}
